package com.wd.health.model.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.wd.health.R;
import com.wd.health.model.bean.PopularBean;

import java.util.List;

/**
 * @ProjectName:shopmall
 * @Package:com.bawei.myhealth.model.adapter
 * @ClassName:PopAdapter
 * @UpdateUser: 裴童童
 * @date: 2020/12/9
 */
public class PopAdapter extends RecyclerView.Adapter<PopAdapter.ViewHolder>{
    private List<PopularBean.ResultBean> list;
    private Context context;

    public PopAdapter(List<PopularBean.ResultBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(View.inflate(context,R.layout.item_pop,null));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.name.setText(list.get(position).getName());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private final TextView name;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.tv_pop_name);
        }
    }
} 
